package com.whmnx.chitchat.ui.book;

import androidx.recyclerview.widget.DefaultItemAnimator;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.whmnx.chitchat.R;
import com.whmnx.chitchat.adapter.DepartmentAdapter;
import com.whmnx.chitchat.base.BaseActivity;
import com.whmnx.chitchat.bean.DepartmentDean;
import com.whmnx.chitchat.constants.Constants;
import com.whmnx.chitchat.http.CallBack;
import com.whmnx.chitchat.http.HttpClient;

import java.util.HashMap;
import java.util.Map;

import butterknife.BindView;

/**
 * author : huang
 * date   : 2020/7/28 0028 16:57
 * version: 1.0
 * @author Administrator
 */
public class DepartmentPerActivity extends BaseActivity {
    @BindView(R.id.rl_dep)
    RecyclerView rlDep;
    @Override
    protected void loadViewLayout() {
        setContentView(R.layout.department_activity);
    }

    @Override
    protected void loadData() {
        rlDep.setLayoutManager(new LinearLayoutManager(this));
        rlDep.setItemAnimator(new DefaultItemAnimator());
        DepartmentAdapter depAdapter = new DepartmentAdapter(this);
        rlDep.setAdapter(depAdapter);


        String OrganizeId = getIntent().getStringExtra("OrganizeId");
        String DepartmentId = getIntent().getStringExtra("DepartmentId");
        String depName = getIntent().getStringExtra("name");
        setTitle(depName);
        Map<String, Object> params = new HashMap<>();
        params.put("OrganizeId", OrganizeId);
        params.put("DepartmentID", DepartmentId);
        HttpClient.get(this, Constants.GETDEPARTMENTLIST, params, new CallBack<DepartmentDean>() {
            @Override
            public void onSuccess(DepartmentDean result) {
                depAdapter.addAll(result.getDepartment());
            }
        });
    }
}
